package com.jemframework.domain.delegator;

import java.util.HashMap;
import java.util.Map;

import com.jemframework.Initializable;

public abstract class AbstractDelegatorFactory implements DelegatorFactory, Initializable {

  private Map<Integer, PrePersistDelegator> prePersistMap = new HashMap<Integer, PrePersistDelegator>();
  private Map<Integer, PreUpdateDelegator> preUpdateMap = new HashMap<Integer, PreUpdateDelegator>();

  public AbstractDelegatorFactory() {
    super();
  }

  public void initialize() {
    initPrePersisDelegators(prePersistMap);
    initPreUpdateDelegators(preUpdateMap);
  }

  protected abstract void initPrePersisDelegators(Map<Integer, PrePersistDelegator> mapping);

  protected abstract void initPreUpdateDelegators(Map<Integer, PreUpdateDelegator> mapping);

  public PrePersistDelegator getPrePersistDelegator(int anEntityType) {
    return prePersistMap.get(anEntityType);
  }

  public PreUpdateDelegator getPreUpdateDelegator(int anEntityType) {
    return preUpdateMap.get(anEntityType);
  }
}
